import React, { Component } from "react";
import { Button, message } from "antd";
import axios from "axios";
import qs from "qs";

export default class EnableMeeting extends Component {
  constructor(props) {
    super(props);
    this.state = {};
  }
  /**启用会议 */
  enableMeeting = () => {
    if (this.props.selectedRowKeys.length === 0) {
      message.error("没有选中数据");
      return;
    }
    let meetingArr = "";
    meetingArr += this.props.selectedRowKeys.map((id) => {
      return id;
    });

    axios
      .post("enableMeeting.rst", qs.stringify({ delArr: meetingArr }))
      .then((res) => {
        let response = res.data;
        console.log(response);
        if (response.resultCode === 0) {
          message.success("会议启用成功");
          this.props.getDataSource();
        } else {
          message.error("启用失败，请检查所选人员是否在日程中心的人员机构中");
        }
      })
      .catch((error) => {
        console.log(error);
        message.error("启用失败，请检查所选人员是否在日程中心的人员机构中");
      });
  };
  /**禁用会议 */
  disableMeeting = () => {
    if (this.props.selectedRowKeys.length === 0) {
      message.error("没有选中数据");
      return;
    }
    let meetingArr = "";
    meetingArr += this.props.selectedRowKeys.map((id) => {
      return id;
    });

    axios
      .post("disableMeeting.rst", qs.stringify({ delArr: meetingArr }))
      .then((res) => {
        let response = res.data;
        console.log(response);
        if (response.resultCode === 0) {
          message.success("会议禁用成功");
          this.props.getDataSource();
        } else {
          message.error("会议禁用失败");
        }
      })
      .catch((error) => {
        console.log(error);
        message.error("会议禁用失败");
      });
  };
  componentDidMount() {}

  render() {
    return (
      <>
        <Button type="primary" onClick={this.enableMeeting}>
          启用
        </Button>
        <Button type="primary" onClick={this.disableMeeting}>
          禁用
        </Button>
      </>
    );
  }
}
